package com.zhang.authoritycenter.controller.sys;

import com.zhang.authoritycenter.common.model.dto.sys.SystemDirectionCategoryReqDTO;
import com.zhang.authoritycenter.service.ISysDirectionCategoryService;
import com.zhang.infrastructure.api.authority.SysLogModuleEnum;
import com.zhang.infrastructure.aspect.OperatorLog;
import com.zhang.infrastructure.model.KingHoodResponseVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * <p>
 * 系统数据字典表 前端控制器
 * </p>
 *
 * @author KingHood
 * @since 2023-12-20
 */
@RestController
@RequestMapping("/sysDirectionCategory")
public class SysDirectionCategoryController {
    @Autowired
    private ISysDirectionCategoryService sysCategoryService;

    /**
     * 查询所有规格列表
     *
     * @author jp
     * @date 2023/12/21
     */
    @PostMapping(value = "/queryAllDirectionCategory")
    public KingHoodResponseVO queryAllDirectionCategory(){
        return KingHoodResponseVO.success(sysCategoryService.queryAllDirectionCategory());
    }

    /**
     * 新增更新规格
     *
     * @param dirReq
     * @author jp
     * @date 2023/12/21
     */
    @OperatorLog(module = SysLogModuleEnum.Type.AUTHORITY_DIRECTION,content = "数据字典管理-新增、修改字典类别")
    @PostMapping(value = "/addOrUpdate")
    public KingHoodResponseVO addOrUpdate(@Valid @RequestBody SystemDirectionCategoryReqDTO dirReq){
        sysCategoryService.addorUpdate(dirReq);
        return KingHoodResponseVO.success();
    }


    /**
     * 根据id删除规格
     *
     * @param id id
     * @author jp
     * @date 2023/12/21
     */
    @OperatorLog(module = SysLogModuleEnum.Type.AUTHORITY_DIRECTION,content = "数据字典管理-删除字典值类别")
    @RequestMapping(value = "/delDirectionCategory/{id}")
    public KingHoodResponseVO delDirectionByids(@PathVariable("id") Long id){
        sysCategoryService.delDirectionByid(id);
        return KingHoodResponseVO.success();
    }


    /**
     * 根据ID查询详情
     *
     * @param id id
     * @author jp
     * @date 2023/12/21
     */
    @PostMapping(value = "/detailDirection/{id}")
    public KingHoodResponseVO detailDirection(@PathVariable("id") Long id){
        return KingHoodResponseVO.success(sysCategoryService.detailDirection(id));
    }
}
